;;;;;;;;;;;;;;;;;;;;;Deftemplejty

(deftemplate visible (slot Object) (slot PosX) (slot PosY))
(deftemplate field (slot Type) (slot Resource) (slot PosX) (slot PosY))
(deftemplate move (slot Move) (slot MoveX) (slot MoveY))
(deftemplate stat (slot Name) (slot Value))
(deftemplate pozycjaAgenta (slot nazwaPola) (slot wartoscPola))
;====================== Super drapieżnik atakuje miesozerce =============

(defrule atakujBystretke
	(visible (Object BYSTRETKA_MIESOZERNA) (PosX ?x) (PosY ?y))
	(test (< 
		(+ (* ?x ?x) (* ?y ?y) )						; sprawdzamy jaka odleglosc jak jest mniejsza niz 2 to chcemy zabic
		2 )
	)
	=>
	(assert (move (Move kill) (MoveX ?x) (MoveY ?y) ))
	(printout t ZABILEM_MIESOO_WRRR crlf)
)

;===================== Lubi też zabić roślinozerce ======================

(defrule zabijWeganke
	(visible (Object BYSTRETKA_ROSLINOZERNA) (PosX ?x) (PosY ?y))
	(test (< 
		(+ (* ?x ?x) (* ?y ?y) )
		3 )
	)
	=>
	(assert (move (Move kill) (MoveX ?x) (MoveY ?y) ))
	(printout t ZABILEM_WEGANKE_WRRR crlf)
)
;===================== Jedzonko  ==================================
  (defrule jedz
	(and
		(stat (Name food) (Value ?v))
		(test (< ?v 5) )
		(field (Type WORM) (Resource ?r) (PosX 0) (PosY 0) )
	)
	=>
	(assert (move (Move collectWorm) (MoveX 0) (MoveY 0) ) )
)

;jeśli jestem głodny i nie stoje na jedzeniu to szukam jedzenia
	
(defrule sprawdzGore
	(and
		(stat (Name food) (Value ?v))
		(test (< ?v 5) )
		(or
			(field (Type WORM) (Resource ?r) (PosX 0) (PosY 1) )
			(field (Type WORM) (Resource ?r) (PosX 0) (PosY 2) )
		)
	)	
	=>
	(assert (move (Move move) (MoveX 0) (MoveY 1) ) )
)

(defrule sprawdzDol
	(and
		(stat (Name food) (Value ?v))
		(test (< ?v 5) )
		(or
			(field (Type WORM) (Resource ?r) (PosX 0) (PosY -1) )
			(field (Type WORM) (Resource ?r) (PosX 0) (PosY -2) )
		)
	)	
	=>
	(assert (move (Move move) (MoveX 0) (MoveY -1) ) )
)

(defrule sprawdzLewo
	(and
		(stat (Name food) (Value ?v))
		(test (< ?v 5) )
		(or
			(field (Type WORM) (Resource ?r) (PosX -1) (PosY 0) )
			(field (Type WORM) (Resource ?r) (PosX -2) (PosY 0) )
		)
	)	
	=>
	(assert (move (Move move) (MoveX -1) (MoveY 0) ) )
)

(defrule sprawdzPrawo
	(and
		(stat (Name food) (Value ?v))
		(test (< ?v 5) )
		(or
			(field (Type WORM) (Resource ?r) (PosX 1) (PosY 0) )
			(field (Type WORM) (Resource ?r) (PosX 2) (PosY 0) )
		)
	)	
	=>
	(assert (move (Move move) (MoveX 1) (MoveY 0) ) )
)

(defrule sprawdzPraweGoraDol
	(and
		(stat (Name food) (Value ?v))
		(test (< ?v 5) )
		(or
			(field (Type WORM) (Resource ?r) (PosX 1) (PosY 1) )
			(field (Type WORM) (Resource ?r) (PosX 1) (PosY -1) )
		)
	)	
	=>
	(assert (move (Move move) (MoveX 1) (MoveY 0) ) )
)

(defrule sprawdzLeweGoraDol
	(and
		(stat (Name food) (Value ?v))
		(test (< ?v 5) )
		(or
			(field (Type WORM) (Resource ?r) (PosX -1) (PosY 1) )
			(field (Type WORM) (Resource ?r) (PosX -1) (PosY -1) )
		)
	)	
	=>
	(assert (move (Move move) (MoveX -1) (MoveY 0) ) )
)